"use strict"

/**
 * 项目主文件，启动文件
 * sunny
 *  
 */

var commander = require("commander");
var schdl = require("./schdl");
const version = "1.0.0";

commander.version(version)
    .option("-n --newitem [spider-name]", "get newer data")
    .option("-a --all", "")
    .option("-f --category [category-name]", "crawler category")
    .option("-c --collection [collection-name]")
    .option("-t --test", "use spider test mode")
    .option("-w --web", "web view") // web 方式查看
    .usage("-->node index.js [options]")
    .parse(process.argv);

if (commander.collection) {
    schdl.collection = commander.collection;
}

if (commander.category) {
    schdl.category = commander.category;
}

if (commander.newitem) {
    schdl.option = "newitem";
    schdl.spidername = commander.newitem; 
    console.log("schdl.spidername=>" + schdl.spidername);
} else if (commander.all) {
    schdl.option = "all";
} else {
    schdl.option = "exit"; //exit debugger model
}

if (commander.test) {
    schdl.testmodule = "test";
}

if (commander.view || commander.web) {
    require("./web").start();
} else {
    schdl.start();
}